<?php
/**
* @package Pages-and-Items (com_pi_pages_and_items)
* @version 1.5.7
* @copyright Copyright (C) 2006-2010 Carsten Engel. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @author http://www.pages-and-items.com
*/

//no direct access
if(!defined('_VALID_MOS') && !defined('_JEXEC')){
	die('Restricted access');
}

//get vars
if( defined('_JEXEC') ){
	//joomla 1.5
	$task = JRequest::getVar('task', '');
	$sub_task = JRequest::getVar('sub_task', '');	
	$item_type = JRequest::getVar('item_type', '');	
}else{
	//joomla 1.0.x
	$task = mosGetParam( $_REQUEST, 'task', '' );
	$sub_task = mosGetParam( $_REQUEST, 'sub_task', '' );
	$item_type = mosGetParam( $_REQUEST, 'item_type', '' );	
}

//display menubar
if( defined('_JEXEC') ){
	//joomla 1.5
	switch ($task) {
	
		case 'page':
			if($sub_task=='new'){				
				JToolBarHelper::save( 'page_save', _pi_lang_save );						
				JToolBarHelper::apply( 'page_apply', _pi_lang_apply );				
				JToolBarHelper::cancel( 'cancel', _pi_lang_cancel );			
			}else{
				JToolBarHelper::save( 'page_save', _pi_lang_save );							
				JToolBarHelper::apply( 'page_apply', _pi_lang_apply );						
				JToolBarHelper::cancel( 'cancel', _pi_lang_cancel );				
				JToolBarHelper::trash( 'page_trash', _pi_lang_trash, '', '', $listSelect = true );				
				JToolBarHelper::custom( 'page_move_select', 'move.png', 'move_f2.png', _pi_lang_move, $listSelect = false );		
			}		
			break;
			
		case 'item':
			if($sub_task=='new'){
				JToolBarHelper::save( 'item_save', _pi_lang_save_item );				
				JToolBarHelper::apply( 'item_apply', _pi_lang_apply );				
				JToolBarHelper::cancel( 'cancel', _pi_lang_cancel );
			}else{
				JToolBarHelper::save( 'item_save', _pi_lang_save_item );				
				JToolBarHelper::apply( 'item_apply', _pi_lang_apply );				
				JToolBarHelper::cancel( 'cancel', _pi_lang_cancel );				
				JToolBarHelper::trash( 'item_trash', _pi_lang_trash, '', '', $listSelect = true );				
				JToolBarHelper::custom( 'item_move_select', 'move.png', 'move_f2.png', _pi_lang_move, $listSelect = false );
				//JToolBarHelper::custom( 'item_copy_select', 'copy.png', 'copy_f2.png', _pi_lang_copy, $listSelect = false);		
			}		
			break;	
		
		case 'item_move_select':
			JToolBarHelper::save( 'item_move_save', _pi_lang_save );					
			JToolBarHelper::cancel( 'cancel', _pi_lang_cancel );
			break;
			
		case 'page_move_select':
			JToolBarHelper::save( 'page_move_save', _pi_lang_save );					
			JToolBarHelper::cancel( 'cancel', _pi_lang_cancel );
			break;
			
		case 'config':
			JToolBarHelper::save( 'config_save', _pi_lang_save );			
			JToolBarHelper::apply( 'config_apply', _pi_lang_apply );			
			JToolBarHelper::cancel( 'cancel', _pi_lang_cancel );	
			break;
			
		case 'config_itemtype':			
			JToolBarHelper::save( 'config_itemtype_save', _pi_lang_save );			
			JToolBarHelper::apply( 'config_itemtype_apply', _pi_lang_apply );			
			JToolBarHelper::cancel( 'cancel', _pi_lang_cancel );
			break;
			
		case 'plugin':			
			require_once(dirname(__FILE__).'/../../../'.$class_pi->plugin_dir.'/pages_and_items/itemtypes/'.$item_type.'/toolbar.php');		
			break;
			
		case 'config_custom_itemtype':
			if(!$sub_task && $sub_task!='new'){
				JToolBarHelper::custom( 'config_itemtype_render', 'copy.png', 'copy_f2.png', _pi_lang_render_itemtypes, $listSelect = false );
				JToolBarHelper::save( 'config_custom_itemtype_save', _pi_lang_save );
			}			
			JToolBarHelper::apply( 'config_custom_itemtype_apply', _pi_lang_apply );
			if(!$sub_task && $sub_task!='new'){
				JToolBarHelper::trash( 'config_custom_itemtype_delete', _pi_lang_delete, '', '', $listSelect = true );	
			}			
			JToolBarHelper::cancel( 'cancel', _pi_lang_cancel );
			break;	
			
		case 'config_custom_itemtype_field':			
			JToolBarHelper::save( 'config_custom_itemtype_field_save', _pi_lang_save );						
			JToolBarHelper::apply( 'config_custom_itemtype_field_apply', _pi_lang_apply );			
			JToolBarHelper::cancel( 'cancel', _pi_lang_cancel );
			break;	
			
		case 'instance_select':			
			JToolBarHelper::save( 'create_instance', _pi_lang_save );
			JToolBarHelper::cancel( 'cancel', _pi_lang_cancel );
			break;					
		
		default:
			JToolBarHelper::apply( 'root_save', _pi_lang_save );
			break;
	}
	
}else{
	//joomla 1.0.x
	
	mosMenuBar::startTable();
	switch ($task) {
	
		case 'page':
			if($sub_task=='new'){				
				mosMenuBar::save( 'page_save', _pi_lang_save );
				mosMenuBar::spacer();		
				mosMenuBar::apply( 'page_apply', _pi_lang_apply );
				mosMenuBar::spacer();
				mosMenuBar::cancel( 'cancel', _pi_lang_cancel );				
			}else{
				mosMenuBar::save( 'page_save', _pi_lang_save );		
				mosMenuBar::spacer();		
				mosMenuBar::apply( 'page_apply', _pi_lang_apply );
				mosMenuBar::spacer();		
				mosMenuBar::cancel( 'cancel', _pi_lang_cancel );
				mosMenuBar::spacer();
				mosMenuBar::trash( 'page_trash', _pi_lang_trash, '', '', $listSelect = true );
				mosMenuBar::spacer();
				mosMenuBar::custom( 'page_move_select', 'move.png', 'move_f2.png', _pi_lang_move, $listSelect = false );		
			}		
			break;
			
		case 'item':
			if($sub_task=='new'){
				mosMenuBar::save( 'item_save', _pi_lang_save_item );
				mosMenuBar::spacer();
				mosMenuBar::apply( 'item_apply', _pi_lang_apply );
				mosMenuBar::spacer();
				mosMenuBar::cancel( 'cancel', _pi_lang_cancel );
			}else{
				mosMenuBar::save( 'item_save', _pi_lang_save_item );		
				mosMenuBar::spacer();
				mosMenuBar::apply( 'item_apply', _pi_lang_apply );
				mosMenuBar::spacer();
				mosMenuBar::cancel( 'cancel', _pi_lang_cancel );
				mosMenuBar::spacer();
				mosMenuBar::trash( 'item_trash', _pi_lang_trash, '', '', $listSelect = true );
				mosMenuBar::spacer();
				mosMenuBar::custom( 'item_move_select', 'move.png', 'move_f2.png', _pi_lang_move, $listSelect = false );
				//mosMenuBar::spacer();	
				//mosMenuBar::custom( 'item_copy_select', 'copy.png', 'copy_f2.png', _pi_lang_copy);			
			}		
			break;	
		
		case 'item_move_select':
			mosMenuBar::save( 'item_move_save', _pi_lang_save );
			mosMenuBar::spacer();		
			mosMenuBar::cancel( 'cancel', _pi_lang_cancel );
			break;
			
		case 'page_move_select':
			mosMenuBar::save( 'page_move_save', _pi_lang_save );
			mosMenuBar::spacer();		
			mosMenuBar::cancel( 'cancel', _pi_lang_cancel );
			break;
			
		case 'config':
			mosMenuBar::save( 'config_save', _pi_lang_save );
			mosMenuBar::spacer();
			mosMenuBar::apply( 'config_apply', _pi_lang_apply );
			mosMenuBar::spacer();
			mosMenuBar::cancel( 'cancel', _pi_lang_cancel );	
			break;
			
		case 'config_itemtype':
			mosMenuBar::save( 'config_itemtype_save', _pi_lang_save );
			mosMenuBar::spacer();
			mosMenuBar::apply( 'config_itemtype_apply', _pi_lang_apply );
			mosMenuBar::spacer();
			mosMenuBar::cancel( 'cancel', _pi_lang_cancel );
			break;
			
		case 'config_custom_itemtype':
			if(!$sub_task && $sub_task!='new'){
				mosMenuBar::custom( 'config_itemtype_render', 'copy.png', 'copy_f2.png', _pi_lang_render_itemtypes, $listSelect = false );				
				mosMenuBar::spacer();
				mosMenuBar::save( 'config_custom_itemtype_save', _pi_lang_save );
				mosMenuBar::spacer();
			}
			mosMenuBar::apply( 'config_custom_itemtype_apply', _pi_lang_apply );
			mosMenuBar::spacer();
			if(!$sub_task && $sub_task!='new'){
				mosMenuBar::trash( 'config_custom_itemtype_delete', _pi_lang_delete );
				mosMenuBar::spacer();
			}
			mosMenuBar::cancel( 'cancel', _pi_lang_cancel );
			break;
			
		case 'config_custom_itemtype_field':			
			mosMenuBar::save( 'config_custom_itemtype_field_save', _pi_lang_save );
			mosMenuBar::spacer();			
			mosMenuBar::apply( 'config_custom_itemtype_field_apply', _pi_lang_apply );
			mosMenuBar::spacer();
			mosMenuBar::cancel( 'cancel', _pi_lang_cancel );
			break;			
			
		case 'plugin':			
			require_once(dirname(__FILE__).'/../../../mambots/pages_and_items/itemtypes/'.$item_type.'/toolbar.php');		
			break;				
			
		case 'instance_select':			
			mosMenuBar::save( 'create_instance', _pi_lang_save );
			mosMenuBar::cancel( 'cancel', _pi_lang_cancel );
			break;			
		
		default:
			mosMenuBar::apply( 'root_save', _pi_lang_save );
			break;
	}	
	mosMenuBar::endTable();
}

?>